//
//  NvDraftModel.m
//  NvSellerShow
//
//  Created by Meicam on 2017/3/20.
//  Copyright © 2017年 Meicam. All rights reserved.
//

#import "NvDraftModel.h"
#import "Utils.h"


@implementation NvDraftModel
- (instancetype)initWithDraftDictianary:(NSDictionary *)draftDic {
    if(self = [super init]) {
        self.draftDic = draftDic.copy;
        self.draftId = [self.draftDic valueForKey:DraftNameKey];
        NvSSVideoCreateScale editmode = ((NSNumber *)[self.draftDic valueForKey:DraftEditModeKey]).intValue;
        if(editmode == NvSSVideoCreateScaleSquare)
            self.draftTypeStr = @"主图视频";
        else
            self.draftTypeStr = @"详情视频";
        
        NSDate *createDate = [self.draftDic valueForKey:DraftCreatedDateKey];
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        self.draftDateStr = [formatter stringFromDate:createDate];
        self.thumbImage = [UIImage imageWithData:[self.draftDic valueForKey:DraftThumbDataKey]];
        
        self.fileDuration = [self.draftDic valueForKey:@"videoDuration"];
        self.fileName = [self.draftDic valueForKey:@"fileName"];
        self.coverImage = [UIImage imageWithData:[self.draftDic valueForKey:@"coverImage"]];
    }
    return self;
}

@end
